'Name:			oeTools.vb														##
'Author:		schachmat														##
'Last modified:	21.8.2007														##
'Status:																		##
'	functionality:			5%													##
'	documentation intern:	0%													##
'	documentation extern:	0%													##
'Comments:																		##
'TODO: ComparExtend																##
'																				##
'																				##
'																				##
'																				##
'#################################################################################

'The MIT License

'Copyright (c) 2007 Markus Teich

'Permission is hereby granted, free of charge, to any person obtaining a copy
'of this software and associated documentation files (the "Software"), to deal
'in the Software without restriction, including without limitation the rights
'to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
'copies of the Software, and to permit persons to whom the Software is
'furnished to do so, subject to the following conditions:

'The above copyright notice and this permission notice shall be included in
'all copies or substantial portions of the Software.

'THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
'IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
'FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
'AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
'LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
'OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
'THE SOFTWARE.

Namespace Core
    Public Class oeTools

        Public Shared Function Swap(Of T)(ByRef val1 As T, ByRef val2 As T) As T
            Dim temp As T = val1
            val1 = val2
            val2 = temp
        End Function

        Public Shared Function oeMax(Of T As {IComparable(Of T)})(ByVal a As T, ByVal b As T) As T
            Return CType(IIf(a.CompareTo(b) > 0, a, b), T)
        End Function

        Public Shared Function oeMin(Of T As {IComparable(Of T)})(ByVal a As T, ByVal b As T) As T
            Return CType(IIf(a.CompareTo(b) < 0, a, b), T)
        End Function

        Public Shared Function ByteToHex(ByVal Src As Byte) As String
            If Src < 16 Then
                Return "0" & Convert.ToString(Src, 16)
            Else
                Return Convert.ToString(Src, 16)
            End If
        End Function

    End Class
End Namespace